package com.bilibili.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.bilibili.dao.CommentDao;
import com.bilibili.dao.VideoAndCollectDao;
import com.bilibili.dao.impl.CommentDaoImpl;
import com.bilibili.dao.impl.VideoAndCollectDaoImpl;
import com.bilibili.dto.VideoAndCollect;
import com.bilibili.entity.Page;
import com.bilibili.service.VideoAndCollectService;

public class VideoAndCollectServiceImpl implements VideoAndCollectService {

	VideoAndCollectDao vacDao = new VideoAndCollectDaoImpl();
	CommentDao commentDao = new CommentDaoImpl();
	@Override
	public Page<VideoAndCollect> queryAllCollectById(int userId,int pageNum,int pageSize,String title) {
		// TODO Auto-generated method stub
		List<VideoAndCollect> list = vacDao.queryAllCollectById(userId,pageNum,pageSize,title);
		List<VideoAndCollect> totalList = new ArrayList<VideoAndCollect>();
		for (VideoAndCollect v : list) {
			v.setCommentNum(commentDao.selectVideoPlayNum(v.getVideoId()));
			totalList.add(v);
		}
		int totalRows = vacDao.queryAllCollectNum(userId,title);
		Page<VideoAndCollect> VideoAndCollectPage = new Page<VideoAndCollect>(totalList,pageNum,pageSize,totalRows);
		return VideoAndCollectPage;
	}

}
